using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SailHero.Soft.FrameWork.Models;

namespace SailHero.Soft.FrameWork.Mapping.HJT212DB
{
    public class CodeItemMap : EntityTypeConfiguration<CodeItem>
    {
        public CodeItemMap()
        {
            // Primary Key
            this.HasKey(t => new { t.TypeID, t.ItemID, t.CodeID });

            // Properties
            this.Property(t => t.TypeID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ItemID)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.CodeID)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.ItemName)
                .HasMaxLength(90);

            this.Property(t => t.Diminutive)
                .HasMaxLength(20);

            this.Property(t => t.InputCode)
                .HasMaxLength(50);

            this.Property(t => t.StdCode)
                .HasMaxLength(20);

            this.Property(t => t.StrV1)
                .HasMaxLength(154);

            this.Property(t => t.StrV2)
                .HasMaxLength(154);

            this.Property(t => t.StrV3)
                .HasMaxLength(154);

            this.Property(t => t.StrV4)
                .HasMaxLength(154);

            this.Property(t => t.StrV5)
                .HasMaxLength(154);

            this.Property(t => t.Notes)
                .HasMaxLength(254);

            // Table & Column Mappings
            this.ToTable("CodeItem");
            this.Property(t => t.TypeID).HasColumnName("TypeID");
            this.Property(t => t.ItemID).HasColumnName("ItemID");
            this.Property(t => t.CodeID).HasColumnName("CodeID");
            this.Property(t => t.ItemName).HasColumnName("ItemName");
            this.Property(t => t.Diminutive).HasColumnName("Diminutive");
            this.Property(t => t.InputCode).HasColumnName("InputCode");
            this.Property(t => t.CodeProp).HasColumnName("CodeProp");
            this.Property(t => t.StdCode).HasColumnName("StdCode");
            this.Property(t => t.IntV1).HasColumnName("IntV1");
            this.Property(t => t.IntV2).HasColumnName("IntV2");
            this.Property(t => t.StrV1).HasColumnName("StrV1");
            this.Property(t => t.StrV2).HasColumnName("StrV2");
            this.Property(t => t.StrV3).HasColumnName("StrV3");
            this.Property(t => t.StrV4).HasColumnName("StrV4");
            this.Property(t => t.StrV5).HasColumnName("StrV5");
            this.Property(t => t.Notes).HasColumnName("Notes");
            this.Property(t => t.IsAvailability).HasColumnName("IsAvailability");
            this.Property(t => t.OrderNo).HasColumnName("OrderNo");
            this.Property(t => t.MaxV).HasColumnName("MaxV");
            this.Property(t => t.MinV).HasColumnName("MinV");
        }
    }
}
